<?php 
require_once('db.php');
require_once('service/users.php');
require_once('service/categories.php');

session_start();

header('Content-type: application/json');

//$data = json_decode($_POST['data'], true);

$data = $_POST['data'];
$input = $data['input'];

switch ($data['method'])
{
    case "signup":
        echo json_encode(signup($input['email'],
                                $input['userName'],
                                $input['mobileId']));
	break;
    case "getCategories"
        echo json_encode(getCategories());
        break;
    case "findUser"
        echo json_encode(findUser($input['email']));
        break;
    case "createGame"
        echo json_encode(createGame($input['userId'],
                                    $input['friendUserId'],
                                    $input['categoryId'],
                                    $input['numQuestions']));
    default:
        echo json_encode('error in da house!');
        break;
}

?>
